
<%@ page import="com.capgemini.rdlgae.domain.Commande"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<g:set var="entityName"
	value="${message(code: 'commande.label', default: 'Commande')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
</head>
<body>
<div class="nav"><span class="menuButton"><g:link
	class="create" action="create">
	<g:message code="default.nouvelle.label" args="[entityName]" />
</g:link></span></div>
<div class="body">
<h1>Liste des commandes</h1>
<g:if test="${flash.message}">
	<div class="message">
	${flash.message}
	</div>
</g:if>
<div class="list"><g:each in="${commandeInstanceList}" status="i"
	var="commandeInstance">

	<g:if test="${date != commandeInstance.dateCommande }">
		<g:set var="date" value="${commandeInstance.dateCommande}" />
		<g:set var="total" value="${0}" />
		<h2>Le <g:formatDate date="${commandeInstance.dateCommande}"
			format="EEEE d MMMM" /> <g:isRead
			date="${commandeInstance.dateCommande}" /></h2>
			<g:link class="create" controller="commande" action="envoi" onclick="return confirm('Etes vous sûr de vouloir envoyer la commande au restaurant de la gare ? Plus personne ne souhaite commander pour aujourdhui ?');" >Envoi de la commande</g:link>

		<br />
		<table>
			<thead>
				<tr>

					<th><g:message code="commande.utilisateur.label"
						default="Utilisateur" /></th>

					<th><g:message code="commande.entree.label" default="Entrée" /></th>

					<th><g:message code="commande.plat.label" default="Plat" /></th>

					<th><g:message code="commande.dessert.label" default="Dessert" /></th>

					<th><g:message code="commande.dessert.label"
						default="Commentaire" /></th>

					<th><g:message code="commande.total.label" default="Total" /></th>

					<th><g:message code="commande.envoyee.label" default="Envoyée" /></th>

					<th><g:message code="commande.action.label" default="Action" /></th>


				</tr>
			</thead>
			<tbody>
	</g:if>
	<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">



		<td width="10%">
		${fieldValue(bean: commandeInstance, field: "utilisateur")}
		</td>

		<td width="10%">
		${fieldValue(bean: commandeInstance, field: "entree")}
		</td>

		<td width="15%">
		${fieldValue(bean: commandeInstance, field: "plat")}
		</td>

		<td width="10%">
		${fieldValue(bean: commandeInstance, field: "dessert")}
		</td>

		<td width="15%">
		${fieldValue(bean: commandeInstance, field: "commentaire")}
		</td>

		<td width="5%" style="text-align: center">
		<b>${fieldValue(bean: commandeInstance, field: "total")} €</b>
		</td>

		<td width="5%" style="text-align: center"><g:if
			test="${commandeInstance.envoyee}">
			<img src="./images/accept.gif" />
		</g:if> <g:else>
			<img src="./images/cross.gif" />
		</g:else></td>

		<td width="15%"><g:link action="show" id="${commandeInstance.id}">Voir/Modifier</g:link></td>

	</tr>
	<g:set var="total" value="${total + commandeInstance.total}" />

	<g:if
		test="${(i+1) >= commandeInstanceList.size || commandeInstanceList.get(i+1)?.dateCommande != date}">

		</tbody>
		</table>
		<br />
		<p style="font-weight:bold;text-align:right">Total : ${total} €</p>
		<br />
		<br />
	</g:if>
</g:each></div>
</body>
</html>
